﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RearLivestock.Beginning.Api.Application.Command.ChangeHouse;
using RearLivestock.Beginning.Api.Application.Command.FarrowingsTable;
using RearLivestock.Common.Dtos;

namespace RearLivestock.Beginning.Api.Controllers
{
    /// <summary>
    /// 猪只转舍控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ChangeHouseController : ControllerBase
    {
        private readonly IMediator mediator;

        public ChangeHouseController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 猪只转舍类型列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> GetChangeHouseType(GetChangeHouseTypeCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 猪只转舍添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> AddChangeHouse(AddChangeHouseCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 猪只转舍列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<PageResultDto<ChangeHouseDto>>> ShowChangeHouse(QueryChangeHouseCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
}
